// 
// Decompiled by Procyon v0.5.36
// 

package com.orange.boot.dev3.service.impl;

import java.util.Map;
import java.util.HashMap;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orange.boot.dev3.entity.vo.insecticideInfoVo;
import java.util.Iterator;
import java.util.List;
import com.orange.boot.dev3.entity.vo.insecticideVo;
import java.util.ArrayList;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.orange.boot.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.orange.boot.dev3.service.InsecticideService;
import com.orange.boot.dev3.entity.Insecticide;
import com.orange.boot.dev3.mapper.InsecticideMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service
public class InsecticideServiceImpl extends ServiceImpl<InsecticideMapper, Insecticide> implements InsecticideService {
    @Autowired
    private InsecticideService insecticideService;

    public InsecticideServiceImpl() {
    }

    public R getInsecticideVo(String insecticideName) {
        QueryWrapper<Insecticide> queryWrapper = new QueryWrapper();
        queryWrapper.like("insecticide_name", insecticideName);
        List<Insecticide> list = this.insecticideService.list(queryWrapper);
        ArrayList<insecticideVo> insecticideVoArrayList = new ArrayList();
        Iterator var5 = list.iterator();

        while(var5.hasNext()) {
            Insecticide insecticide = (Insecticide)var5.next();
            insecticideVo insecticideVo = new insecticideVo();
            insecticideVo.setInsecticideName(insecticide.getInsecticideName());
            insecticideVo.setAttention(insecticide.getAttention());
            insecticideVo.setEmergencyTreatment(insecticide.getEmergencyTreatment());
            insecticideVo.setInstruction(insecticide.getInstruction());
            insecticideVo.setRemarks(insecticide.getRemarks());
            insecticideVo.setEffect(insecticide.getEffect());
            insecticideVoArrayList.add(insecticideVo);
        }

        return R.ok().data("insecticideVoArrayList", insecticideVoArrayList);
    }

    public R getInsecticide(String diseaseName) {
        QueryWrapper<Insecticide> queryWrapper = new QueryWrapper();
        queryWrapper.like("disease_name", diseaseName);
        List<Insecticide> insecticideList = this.insecticideService.list(queryWrapper);
        ArrayList<insecticideInfoVo> list = new ArrayList();
        Iterator var5 = insecticideList.iterator();

        while(var5.hasNext()) {
            Insecticide insecticide = (Insecticide)var5.next();
            insecticideInfoVo insecticideInfoVo = new insecticideInfoVo();
            insecticideInfoVo.setId(insecticide.getId());
            insecticideInfoVo.setType(insecticide.getType());
            insecticideInfoVo.setRemarks(insecticide.getRemarks());
            insecticideInfoVo.setInstruction(insecticide.getInstruction());
            insecticideInfoVo.setInsecticideName(insecticide.getInsecticideName());
            insecticideInfoVo.setEnglishName(insecticide.getEnglishName());
            insecticideInfoVo.setEmergencyTreatment(insecticide.getEmergencyTreatment());
            insecticideInfoVo.setDiseaseName(insecticide.getDiseaseName());
            insecticideInfoVo.setCertificateNumber(insecticide.getCertificateNumber());
            insecticideInfoVo.setAttention(insecticide.getAttention());
            insecticideInfoVo.setActiveConstituent(insecticide.getActiveConstituent());
            insecticideInfoVo.setEffect(insecticide.getEffect());
            list.add(insecticideInfoVo);
        }

        return R.ok().data("list", list);
    }

    public R getInsecticideInfo(String diseaseName) {
        QueryWrapper<Insecticide> queryWrapper = new QueryWrapper();
        queryWrapper.like("disease_name", diseaseName);
        List<Insecticide> insecticideList = this.insecticideService.list(queryWrapper);
        ArrayList<insecticideInfoVo> insecticideInfoVos = new ArrayList();
        Iterator var5 = insecticideList.iterator();

        while(var5.hasNext()) {
            Insecticide insecticide = (Insecticide)var5.next();
            insecticideInfoVo insecticideInfoVo = new insecticideInfoVo();
            insecticideInfoVo.setType(insecticide.getType());
            insecticideInfoVo.setRemarks(insecticide.getRemarks());
            insecticideInfoVo.setInstruction(insecticide.getInstruction());
            insecticideInfoVo.setInsecticideName(insecticide.getInsecticideName());
            insecticideInfoVo.setEnglishName(insecticide.getEnglishName());
            insecticideInfoVo.setEmergencyTreatment(insecticide.getEmergencyTreatment());
            insecticideInfoVo.setDiseaseName(insecticide.getDiseaseName());
            insecticideInfoVo.setCertificateNumber(insecticide.getCertificateNumber());
            insecticideInfoVo.setAttention(insecticide.getAttention());
            insecticideInfoVo.setActiveConstituent(insecticide.getActiveConstituent());
            insecticideInfoVo.setEffect(insecticide.getEffect());
            insecticideInfoVos.add(insecticideInfoVo);
        }

        return R.ok().data("insecticideInfoVos", insecticideInfoVos);
    }

    public R getAllInsecticide(Long current, Long size) {
        Page<Insecticide> pageInsecticide = new Page(current, size);
        new QueryWrapper();
        this.insecticideService.page(pageInsecticide);
        long total = pageInsecticide.getTotal();
        List<Insecticide> insecticideList = pageInsecticide.getRecords();
        ArrayList<insecticideInfoVo> list = new ArrayList();
        Iterator var9 = insecticideList.iterator();

        while(var9.hasNext()) {
            Insecticide insecticide = (Insecticide)var9.next();
            insecticideInfoVo insecticideInfoVo = new insecticideInfoVo();
            insecticideInfoVo.setId(insecticide.getId());
            insecticideInfoVo.setType(insecticide.getType());
            insecticideInfoVo.setRemarks(insecticide.getRemarks());
            insecticideInfoVo.setInstruction(insecticide.getInstruction());
            insecticideInfoVo.setInsecticideName(insecticide.getInsecticideName());
            insecticideInfoVo.setEnglishName(insecticide.getEnglishName());
            insecticideInfoVo.setEmergencyTreatment(insecticide.getEmergencyTreatment());
            insecticideInfoVo.setDiseaseName(insecticide.getDiseaseName());
            insecticideInfoVo.setCertificateNumber(insecticide.getCertificateNumber());
            insecticideInfoVo.setAttention(insecticide.getAttention());
            insecticideInfoVo.setActiveConstituent(insecticide.getActiveConstituent());
            insecticideInfoVo.setEffect(insecticide.getEffect());
            list.add(insecticideInfoVo);
        }

        HashMap<String, Object> map = new HashMap();
        map.put("total", total);
        map.put("rows", list);
        return R.ok().data(map);
    }
}